package com.ruoyi.web.controller.line;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.yanjing.domain.Area;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.Line;
import com.ruoyi.yanjing.service.ILineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线路信息Controller
 * 
 * @author whz
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/yanjing/line")
public class LineController extends BaseController
{
    @Autowired
    private ILineService lineService;

    /**
     * 查询线路列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:selectAllLineList')")
    @GetMapping("/selectAllLineList")
    public AjaxResult selectAllLineList(Line line)
    {
        return success(lineService.selectLineList(line));
    }


    /**
     * 查询区域线路信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:selectLineAndAreaInfoList')")
    @GetMapping("/selectLineAndAreaInfoList")
    public TableDataInfo selectLineAndAreaInfoList(Line line)
    {
        startPage();
        List<Line> list = lineService.selectLineAndAreaInfoList(line);
        return getDataTable(list);
    }

    /**
     * 查询线路信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(Line line)
    {
        startPage();
        List<Line> list = lineService.selectLineList(line);
        return getDataTable(list);
    }


    /**
     * 导出线路信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:export')")
    @Log(title = "线路信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Line line)
    {
        List<Line> list = lineService.selectLineList(line);
        ExcelUtil<Line> util = new ExcelUtil<Line>(Line.class);
        util.exportExcel(response, list, "线路信息数据");
    }

    /**
     * 获取线路信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(lineService.selectLineById(id));
    }

    /**
     * 新增线路信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:add')")
    @Log(title = "线路信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Line line)
    {
        return toAjax(lineService.insertLine(line));
    }

    /**
     * 修改线路信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:edit')")
    @Log(title = "线路信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Line line)
    {
        return toAjax(lineService.updateLine(line));
    }

    /**
     * 删除线路信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:line:remove')")
    @Log(title = "线路信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(lineService.deleteLineByIds(ids));
    }
}
